<?php

class InstallController extends Controller
{
    public function actionIndex()
    {
        $sql="
               CREATE TABLE IF NOT EXISTS `content_menu` (
              `id` int(16) NOT NULL AUTO_INCREMENT,
              `name` varchar(128) NOT NULL,
              `text` varchar(240) DEFAULT NULL,
              `link` varchar(240) NOT NULL,
              `dataId` int(10) DEFAULT NULL,
              `sort` int(4) NOT NULL DEFAULT '0',
              `isActive` int(2) NOT NULL DEFAULT '1',
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
         ";

        $db=Yii::app()->db;
        $db->createCommand($sql)->query();

        $error=implode(' ',$db->stats);

        if($error=='0 0'){
            $text=Yii::t('modules/main','installOkMessage',array(
                '{module}'=>'Content Menu',
            ));
        }else{
            $text=Yii::t('modules/main','installErrorMessage',array(
                '{module}'=>'Content Menu',
                '{error}'=>$error,
            ));
        }
        $this->render('index',array(
            'text'=>$text,
        ));
    }
}